/*
 *  $Id: PrayOfCourage.cs 1067 2010-05-21 11:00:43Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Light.Spells {
    public class PrayOfCourage: Abilities.Pray.PrayEnchantmentCard {
        public PrayOfCourage(): base("001_l_s_pray_of_courage") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Light;
            Value = 100;
            AddManaCost(ElementType.Light, 2);
        }

        protected override EnchantmentAffect CreateEnchantment() {
            return new PrayOfCourageAffect();
        }

        private class PrayOfCourageAffect: EnchantmentAffect<PrayOfCourage> {
            private static readonly Languages.CardPhrase<PrayOfCourage> Action = new Languages.CardPhrase<PrayOfCourage>("action");

            public PrayOfCourageAffect() {
                Add(new Abilities.Pray.PrayBonus(DoPray));
            }

            private void DoPray(Creature prayer) {
                Game.Current.Log.Add(Action.Phrase, prayer);
                prayer.Owner.AddAffect<PrayOfCouragePrayAffect>();
            }
        }

        private class PrayOfCouragePrayAffect : SpellAffect<PrayOfCourage> {
            public PrayOfCouragePrayAffect() : base(true) {
                Add(new TimeAffect(4, new PrayOfCourageAura()));
            }
        }

        private class PrayOfCourageAura: CreatureAuraAffect {
            public PrayOfCourageAura(): base(true, false) {}

            public override string Id {
                get { return AffectManager.GetCardId<PrayOfCourage>("aura"); }
            }

            protected override Affect CreateSubAffect() {
                return new PrayOfCourageAuraAffect();
            }
        }

        private class PrayOfCourageAuraAffect : SpellAffect<PrayOfCourage> {
            public PrayOfCourageAuraAffect() : base(true) {
                Add(new Affects.Fearless());
                Add(new Affects.SorrowIgnore());
            }
        }
    }
}
